#pragma warning(disable : 4996)
#include"List.h"
void InIt(List* list)
{
	list->capicity = 4;
	ListDate* tail = (ListDate*)malloc(sizeof(ListDate) * list->capicity);
	if (!tail)
	{
		perror("malloc fail");
	}
	list->head = tail;
	list->count = 0;
}

void ListDestory(List* list)
{
	free(list->head);
	list->capicity = 0;
	list->count = 0;
	list->head = NULL;
}


void Expansion(List* list)
{
	assert(list != NULL);
	ListDate* tail = (ListDate*)realloc(list->head, sizeof(ListDate) * list->capicity * 2);
	if (tail == NULL)
	{
		perror("relloc fail");
	}
	list->head = tail;
	list->capicity *= 2;
}

void Push(List*list ,ListDate x)
{
	assert(list != NULL);
	if (list->count == list->capicity)
	{
		Expansion(list);
	}
	list->head[list->count] = x;
	list->count++;
}

bool Empty(List* list)
{
	assert(list != NULL);
	if (list->count == 0)
	{
		return true;

	}
	else
	{
		return false;
	}

}

ListDate Pop(List* list)
{
	assert(Empty(list)!= true);
	list->count--;
	return list->head[list->count];
	
}
//for (int i = 0; i < obj->pop.head->count - 1; i++)
//{
//	push(&obj->pop.head, pop(&obj->push.head));
//}